using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Presentation.Contracts;
using Presentation;

namespace ProjektZespolowy
{
    public partial class UserLogInArt : Page, IUserLogInArtView
    {
        private int _idArt = 0;
        /// <summary>
        /// Presenter.
        /// </summary>
        private UserLogInArtPresenter presenter;

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            presenter = new UserLogInArtPresenter(this);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string idString = Request.QueryString["id"];
            int.TryParse(idString, out _idArt);

            if (!Page.IsPostBack)
            {
                if (int.TryParse(idString, out _idArt))
                {
                    //w url poprawny int
                    presenter.ReadArtByArtId(_idArt);
                }
                else
                {
                    DisplayError("Podano niepoprawny numer publikacji");
                }
            }
        }

        public void DisplayError(string error)
        {
            mvwPage.SetActiveView(vwError);
            lblError.Text = error.Trim();
        }


        
    }
}
